*Replication Code for “Social Context and Local Political Knowledge”
*Nick Clark and Todd Makse
*July 2025
*All analyses conducted in STATA IC 16.1

*Table 1
use "C:\SCLPK Replication Data.dta" 
tabstat npk1 npk2 npk3 npk4 lpk1 lpk2 lpk3 lpk4 if polknow_search==0 & philly_error!=1

*Figure 1
hist zcta_homeage if polknow_search==0  & philly_error!=1, bin(10) saving(homeage) percent
hist zcta_drive if polknow_search==0  & philly_error!=1 , bin(10) saving(drive) percent
hist zcta_dens if polknow_search==0  & philly_error!=1, bin(10) saving(dens) percent
gr combine homeage.gph drive.gph dens.gph, col(1)

*Table 2
correl zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden if polknow_search==0  & philly_error!=1

Table 3
*Likelihood ratio tests
mixed polknow_loc if polknow_search==0  & philly_error!=1
est store est1
mixed polknow_loc if polknow_search==0  & philly_error!=1 || citycode:
est store est2
lrtest est1 est2
*Local model
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
*Marginal effects
margins, at(zcta_homeage=(21 82))
*National model
mixed polknow_nat loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
*Marginal effects
margins, at(zcta_homeage=(21 82))
margins, at(zcta_dens=(6.68 9.56))
margins, at(zcta_drive=(.445 .87))
margins, at(zcta_medinc=(10.35 11.57))
margins, at(zcta_herf=(.327 .774))
margins, at(zcta_biden=(.422 .953))

*Figure 2
melogit lpk1 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0 & philly_error!=1 || citycode:
margins, dydx(*) post
coefplot, order(zcta_homeage zcta_dens zcta_drive zcta_biden zcta_herf zcta_medinc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female) rescale(zcta_homeage = 61 loc_media = 12 zcta_dens=2.88 zcta_drive=.425 zcta_medinc=1.22 zcta_herf=.447 zcta_biden=.531 lived_city=3 educ4=3 income4=3 age=53) xline(0) 

melogit lpk2 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0 & philly_error!=1 || citycode:
margins, dydx(*) post
coefplot, order(zcta_homeage zcta_dens zcta_drive zcta_biden zcta_herf zcta_medinc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female) rescale(zcta_homeage = 61 loc_media = 12 zcta_dens=2.88 zcta_drive=.425 zcta_medinc=1.22 zcta_herf=.447 zcta_biden=.531 lived_city=3 educ4=3 income4=3 age=53) xline(0) 

melogit lpk3 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0 & philly_error!=1 || citycode:
margins, dydx(*) post
coefplot, order(zcta_homeage zcta_dens zcta_drive zcta_biden zcta_herf zcta_medinc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female) rescale(zcta_homeage = 61 loc_media = 12 zcta_dens=2.88 zcta_drive=.425 zcta_medinc=1.22 zcta_herf=.447 zcta_biden=.531 lived_city=3 educ4=3 income4=3 age=53) xline(0) 

melogit lpk4 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0 & philly_error!=1 || citycode:
margins, dydx(*) post
coefplot, order(zcta_homeage zcta_dens zcta_drive zcta_biden zcta_herf zcta_medinc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female) rescale(zcta_homeage = 61 loc_media = 12 zcta_dens=2.88 zcta_drive=.425 zcta_medinc=1.22 zcta_herf=.447 zcta_biden=.531 lived_city=3 educ4=3 income4=3 age=53) xline(0) xscale(range(-.15 .45)) 

*Table 4
xtile homeage4 = zcta_homeage, nq(4)
tabstat educ4 homeown loc_media lived_city, by(homeage4)
xtile dens4 = zcta_dens, nq(4)
tabstat educ4 income4 homeown loc_media lived_city, by(dens4)
xtile drive4 = zcta_drive, nq(4)
tabstat educ4 income4 homeown loc_media lived_city, by(drive4)

*Online Appendix

*Table A-1
use "C:\SCLPK City Sample Representativeness.dta" 
ttest totpop, by(insurvey)
ttest whitepct, by(insurvey)
ttest blackpct, by(insurvey)
ttest asianpct, by(insurvey)
ttest hisppct, by(insurvey)
ttest femalepct, by(insurvey)
ttest medage, by(insurvey)
ttest baplus, by(insurvey)
ttest medinc, by(insurvey)
ttest marrpct, by(insurvey)

*Table A-2
use "C:\SCLPK Replication Data.dta" 
tab citycode if polknow_search==0  & philly_error!=1

*Table A-3
sum polknow_loc polknow_nat loc_media homeown lived_city i.pid3a ib4.eth i.educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf if polknow_search==0  & philly_error!=1

*Table A-4 and A-5
*Identification of mayor 
melogit lpk1 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
*Identification of police chief
melogit lpk2 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
*Identification of property assessor role
melogit lpk3 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
*Mayor term length and limits
melogit lpk4 loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:

*Table A-6
*Local
reg polknow_loc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden i.citycode if polknow_search==0  & philly_error!=1 [aweight=weight], cl(zip)
*National
reg polknow_nat loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden i.citycode if polknow_search==0  & philly_error!=1 [aweight=weight], cl(zip)

*Table A-7
*Interactions between individual SES measures and home age
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth income4 age female c.zcta_homeage##c.educ4 zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth educ4 age female c.zcta_homeage##c.income4 zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_nat loc_media homeown lived_city i.pid3a ib4.eth income4 age female c.zcta_homeage##c.educ4 zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_nat loc_media homeown lived_city i.pid3a ib4.eth educ4 age female c.zcta_homeage##c.income4 zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:

*Interactions between individual SES measures and density
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth income4 age female zcta_homeage c.zcta_dens##c.educ4 zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth educ4 age female zcta_homeage c.zcta_dens##c.income4 zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_nat loc_media homeown lived_city i.pid3a ib4.eth income4 age female zcta_homeage c.zcta_dens##c.educ4 zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_nat loc_media homeown lived_city i.pid3a ib4.eth educ4 age female zcta_homeage c.zcta_dens##c.income4 zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:

*Interactions between individual SES measures and commuting
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth income4 age female zcta_homeage zcta_dens c.zcta_drive##c.educ4 zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth educ4 age female zcta_homeage zcta_dens c.zcta_drive##c.income4 zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_nat loc_media homeown lived_city i.pid3a ib4.eth income4 age female zcta_homeage zcta_dens c.zcta_drive##c.educ4 zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:
mixed polknow_nat loc_media homeown lived_city i.pid3a ib4.eth educ4 age female zcta_homeage zcta_dens c.zcta_drive##c.income4 zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 || citycode:

*Table A-8
*Respondents who would like to leave city only  
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 & soc_moveout>2 || citycode:
*Respodents who have lived in city for ten years but at residence for less than 10 years
mixed polknow_loc loc_media homeown lived_city i.pid3a ib4.eth educ4 income4 age female zcta_homeage zcta_dens zcta_drive zcta_medinc zcta_herf zcta_biden  if polknow_search==0  & philly_error!=1 & lived_city==3 & lived_res<3 || citycode:
 
*Figure A-1
use "C:\SCLPK Within City Representativeness.dta" 
graph dot actual survey if city==78, over(varnum) saving(rep78) leg(off) title("Austin")
graph dot actual survey if city==14, over(varnum) saving(rep14) leg(off) title("Buffalo")
graph dot actual survey if city==28, over(varnum) saving(rep28) leg(off) title("Charlotte")
graph dot actual survey if city==60, over(varnum) saving(rep60) leg(off) title("Chicago")
graph dot actual survey if city==80, over(varnum) saving(rep80) leg(off) title("Colorado Springs")
graph dot actual survey if city==43, over(varnum) saving(rep43) leg(off) title("Columbus")
graph dot actual survey if city==46, over(varnum) saving(rep46) leg(off) title("Indianapolis")
graph dot actual survey if city==32, over(varnum) saving(rep32) leg(off) title("Jacksonville")
graph dot actual survey if city==89, over(varnum) saving(rep89) leg(off) title("Las Vegas")
graph dot actual survey if city==40, over(varnum) saving(rep40) leg(off) title("Louisville")
graph dot actual survey if city==38, over(varnum) saving(rep38) leg(off) title("Memphis")
graph dot actual survey if city==53, over(varnum) saving(rep53) leg(off) title("Milwaukee")
graph dot actual survey if city==70, over(varnum) saving(rep70) leg(off) title("New Orleans")
graph dot actual survey if city==68, over(varnum) saving(rep68) leg(off) title("Omaha")
graph dot actual survey if city==19, over(varnum) saving(rep19) leg(off) title("Philadelphia")
graph dot actual survey if city==97, over(varnum) saving(rep97) leg(off) title("Portland")
graph dot actual survey if city==92, over(varnum) saving(rep92) leg(off) title("San Diego")
graph dot actual survey if city==85, over(varnum) saving(rep85) leg(off) title("Tucson")
graph dot actual survey if city==74, over(varnum) saving(rep74) leg(off) title("Tulsa")
graph dot actual survey if city==67, over(varnum) saving(rep67) leg(off) title("Wichita")

*Figure A-2
use "C:\SCLPK Replication Data.dta" 
recode citycode (78=1)(14=2)(28=3)(60=4)(80=5)(43=6)(46=7)(32=8)(89=9)(40=10)(38=11)(53=12)(70=13)(68=14)(19=15)(97=16)(92=17)(85=18)(74=19)(67=20), gen(cityorder)
label define cityorder 1 "Austin" 2 "Buffalo" 3 "Charlotte" 4 "Chicago" 5 "Colorado Springs" 6 "Columbus" 7 "Indianapolis" 8 "Jacksonville" 9 "Las Vegas" 10 "Louisville" 11 "Memphis" 12 "Milwaukee" 13 "New Orleans" 14 "Omaha" 15 "Philadelphia" 16 "Portland" 17 "San Diego" 18 "Tucson" 19 "Tulsa" 20 "Wichita"
mean polknow_loc if polknow_search==0 & philly_error!=1, over(cityorder)
est store locmeans
mean polknow_nat if polknow_search==0 & philly_error!=1, over(cityorder)
est store natmeans
coefplot locmeans, recast(bar) citop barwidth(.5)
coefplot natmeans, recast(bar) citop barwidth(.5)

*Figure A-3
recode citycode (78=6)(14=5)(28=20)(60=13)(80=19)(43=9)(46=3)(32=11)(89=15)(40=1) (38=2)(53=17)(70=4)(68=14)(19=16)(97=10)(92=8)(85=12)(74=7)(67=18), gen(cityorder1)
label define cityorder1 6 "Austin"5 "Buffalo"20 "Charlotte"13 "Chicago"19 "Colorado Springs"9 "Columbus"3 "Indianapolis"11 "Jacksonville"15 "Las Vegas"1 "Louisville"2 "Memphis"17 "Milwaukee"4 "New Orleans"14 "Omaha"16 "Philadelphia"10 "Portland"8 "San Diego"12 "Tucson"7 "Tulsa"18 "Wichita"
label values cityorder1 cityorder1

recode citycode (78=8)(14=19)(28=15)(60=11)(80=17)(43=7)(46=9)(32=5)(89=14)(40=1) (38=3)(53=12)(70=13)(68=4)(19=2)(97=10)(92=16)(85=20)(74=6)(67=18), gen(cityorder2)
label define cityorder2 8 "Austin"19 "Buffalo"15 "Charlotte"11 "Chicago"17 "Colorado Springs"7 "Columbus"9 "Indianapolis"5 "Jacksonville"14 "Las Vegas"1 "Louisville"3 "Memphis"12 "Milwaukee"13 "New Orleans"4 "Omaha"2 "Philadelphia"10 "Portland"16 "San Diego"20 "Tucson"6 "Tulsa"18 "Wichita"
label values cityorder2 cityorder2
recode citycode (78=20)(14=4)(28=15)(60=18)(80=7)(43=17)(46=8)(32=6)(89=13)(40=12) (38=1)(53=19)(70=14)(68=9)(19=16)(97=10)(92=5)(85=2)(74=3)(67=11), gen(cityorder3)
label define cityorder3 20 "Austin"4 "Buffalo"15 "Charlotte"18 "Chicago"7 "Colorado Springs"17 "Columbus"8 "Indianapolis"6 "Jacksonville"13 "Las Vegas"12 "Louisville"1 "Memphis"19 "Milwaukee"14 "New Orleans"9 "Omaha"16 "Philadelphia"10 "Portland"5 "San Diego"2 "Tucson"3 "Tulsa"11 "Wichita"
label values cityorder3 cityorder3

recode citycode (78=9)(14=7)(28=13)(60=12)(80=8)(43=18)(46=15)(32=3)(89=6)(40=5) (38=10)(53=14)(70=1)(68=19)(19=4)(97=17)(92=2)(85=20)(74=16)(67=11), gen(cityorder4)
label define cityorder4 9 "Austin"7 "Buffalo"13 "Charlotte"12 "Chicago"8 "Colorado Springs"18 "Columbus"15 "Indianapolis"3 "Jacksonville"6 "Las Vegas"5 "Louisville"10 "Memphis"14 "Milwaukee"1 "New Orleans"19 "Omaha"4 "Philadelphia"17 "Portland"2 "San Diego"20 "Tucson"16 "Tulsa" 11 "Wichita"
label values cityorder4 cityorder4

graph dot lpk1 if polknow_search==0 & philly_error!=1, over(cityorder1) yline(.79, lcolor(black)) exclude0 yscale(range(.5 1)) ylabel (.5 (0.1) 1)
graph dot lpk2 if polknow_search==0 & philly_error!=1, over(cityorder2) yline(.53, lcolor(black)) exclude0 yscale(range(.3 .8)) ylabel (.4 (0.1) .8)
graph dot lpk3 if polknow_search==0 & philly_error!=1, over(cityorder3) yline(.70, lcolor(black)) exclude0 yscale(range(.3 1)) ylabel (.3 (0.1) .9) 
graph dot lpk4 if polknow_search==0 & philly_error!=1, over(cityorder4) yline(.40, lcolor(black)) exclude0 yscale(range(.2 .6)) ylabel (.2 (0.1) .6) 


